using System.Text;
using System.Web.Mvc;
using System.Collections.Generic;
using rmeloni.Models;

namespace rmeloni.Helpers
{
    public static class ImageHelper
    {
        //0 - Image Source
        //1 - Alt Tag
        //2 - Styles
        //3 - Class
        const string ImageTag = "<img src=\"{0}\" alt=\"{1}\" title=\"{1}\" />";

        public static string Thumbnail(this HtmlHelper Helper,
                         string Controllername,
                         string Action,
                         long Id)
        {
            string Imagelocation = ThumbnailLocation(Helper,Controllername, Action, Id);
            
            //WC3 - ALT tag always needed so when not set then set to the filename.
            ProjectRepository prjRepo = new ProjectRepository();
            var projetoid = prjRepo.SelectById(Id);

            return string.Format(ImageTag, Imagelocation, projetoid.Nome);
        }

        public static string ThumbnailLocation(this HtmlHelper Helper,                                 
                                string Controllername,
                                string Action,
                                long Id)
        {
            return string.Format("/{0}/{1}/{2}", Controllername, Action, Id);
            
        }
    }
}